<HeadLayout />

{{title "crates.io: Rust Package Registry" separator=' - ' prepend=true}}
<GoogleJsapi />

<div local-class="application">
  <nav id="header">
    <LinkTo @route="index" @tabindex="-1">
      <img src="/assets/Cargo-Logo-Small.png" id="logo"
           height="100" width="100" alt="Cargo Logo">
    </LinkTo>
    <LinkTo @route="index">
      <h1>
        crates.io
        <span class="subtitle">Rust Package Registry</span>
      </h1>
    </LinkTo>

    <form class='search' action='/search' {{ action "search" on="submit" }} data-test-search-form>
      <input
        type="text"
        class="search"
        name="q"
        id="cargo-desktop-search"
        placeholder="Click or press 'S' to search..."
        value={{this.searchQuery}}
        oninput={{action (mut this.searchQuery) value="target.value"}}
        autocorrect="off"
        autocapitalize="off"
        autofocus="autofocus"
        spellcheck="false"
        required
        data-test-search-input
      >
      <label for="cargo-desktop-search">Search</label>
    </form>

    <div class='nav'>
      <LinkTo @route="crates" @query={{hash letter=null page=1}} data-test-all-crates-link>
        Browse All Crates
      </LinkTo>
      <span class="sep">|</span>
      <Dropdown class="dropdown-container" as |dd|>
        <dd.Trigger class="dropdown">
          Docs
          <span class='arrow'></span>
        </dd.Trigger>

        <dd.Content @tagName="ul" id="doc-links" class="dropdown">
          <li><a href='https://doc.rust-lang.org/cargo/getting-started/'>Getting Started</a></li>
          <li><a href='https://doc.rust-lang.org/cargo/guide/'>Guide</a></li>
          <li><a href='https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html'>Specifying Dependencies</a></li>
          <li><a href='https://doc.rust-lang.org/cargo/reference/publishing.html'>Publishing on crates.io</a></li>
          <li><a href='https://doc.rust-lang.org/cargo/faq.html'>FAQ</a></li>
          <li><a href='https://doc.rust-lang.org/cargo/reference/manifest.html'>Cargo.toml Format</a></li>
          <li><a href='https://doc.rust-lang.org/cargo/reference/build-scripts.html'>Build Scripts</a></li>
          <li><a href='https://doc.rust-lang.org/cargo/reference/config.html'>Configuration</a></li>
          <li><a href='https://doc.rust-lang.org/cargo/reference/pkgid-spec.html'>Package ID specs</a></li>
          <li><a href='https://doc.rust-lang.org/cargo/reference/environment-variables.html'>Environment Variables</a></li>
          <li><a href='https://doc.rust-lang.org/cargo/reference/source-replacement.html'>Source Replacement</a></li>
          <li><a href='https://doc.rust-lang.org/cargo/reference/external-tools.html'>External Tools</a></li>
          <li><LinkTo @route="policies">Policies</LinkTo></li>
          <li><LinkTo @route="category-slugs">List of category slugs</LinkTo></li>
        </dd.Content>
      </Dropdown>
      <span class="sep">|</span>
      {{#if this.session.currentUser}}
        <Dropdown class="dropdown-container" data-test-user-menu as |dd|>
          <dd.Trigger class="dropdown" data-test-toggle>
            <UserAvatar @user={{this.session.currentUser}} @size="small" data-test-avatar />
            {{ this.session.currentUser.name }}
            <span class='arrow'></span>
          </dd.Trigger>

          <dd.Content @tagName="ul" class="dropdown current-user-links">
            <li><LinkTo @route="dashboard">Dashboard</LinkTo></li>
            <li><LinkTo @route="me">Account Settings</LinkTo></li>
            <li><LinkTo @route="me.pending-invites">Owner Invites</LinkTo></li>
            <li class='last'><LinkTo @route="logout">Sign Out</LinkTo></li>
          </dd.Content>
        </Dropdown>
      {{else}}
        <LinkTo @route="login" data-test-login-link>
          {{svg-jar "lock"}}
          Log in with GitHub
        </LinkTo>
      {{/if}}
    </div>

    <div class='menu'>
      <Dropdown class="dropdown-container" as |dd|>
        <dd.Trigger class="dropdown">
          Menu
          <span class='arrow'></span>
        </dd.Trigger>
        <dd.Content @tagName="ul" class="dropdown current-user-links">
          <li><LinkTo @route="crates">Browse All Crates</LinkTo></li>
          {{#if this.session.currentUser}}
            <li><LinkTo @route="dashboard">Dashboard</LinkTo></li>
            <li><LinkTo @route="me">Account Settings</LinkTo></li>
            <li><LinkTo @route="me.pending-invites">Owner Invites</LinkTo></li>
            <li class='last'><LinkTo @route="logout">Sign Out</LinkTo></li>
          {{else}}
            <li><LinkTo @route="login">Log in with GitHub</LinkTo></li>
          {{/if}}
        </dd.Content>
      </Dropdown>
    </div>

    <div class='links'>
    </div>
  </nav>

  <form id='mobile-search' class='search' action='/search' {{ action "search" on="submit" }} >
    <input
      type="text"
      class="search"
      name="q"
      id="cargo-mobile-search"
      placeholder="Search"
      value={{this.searchQuery}}
      oninput={{action (mut this.searchQuery) value="target.value"}}
      autocorrect="off"
      required
    >
    <label for="cargo-mobile-search">Search</label>
  </form>

  <main local-class="main">
    <FlashMessage @message={{this.flashMessages.message}} />

    {{outlet}}
  </main>

  <footer local-class='after-main-links'>
    <a href='https://doc.rust-lang.org/cargo/getting-started/installation.html'>Install</a>
    <span local-class="sep">|</span>
    <a href='https://doc.rust-lang.org/cargo/'>Getting Started</a>
    <span local-class="sep">|</span>
    <a href='https://doc.rust-lang.org/cargo/guide/'>Guide</a>
    <span local-class="sep">|</span>
    <a href='mailto:help@crates.io'>Send us an email</a>
    <span local-class="sep">|</span>
    <a href='https://www.rust-lang.org/policies/security'>Report a security issue</a>
    <span local-class="sep">|</span>
    <a href='https://www.rust-lang.org/policies/privacy'>Privacy notice</a>
    <span local-class="sep">|</span>
    <LinkTo @route="policies">Policies</LinkTo>
  </footer>

  <a href='https://github.com/rust-lang/crates.io' local-class='fork-me'>
    <img src='/assets/forkme.png' alt="Fork me on GitHub">
  </a>
</div>